#ifndef KEYDELEGATE_H
#define KEYDELEGATE_H

#include <QObject>
#include <QString>
#include <QVariant>
#include <QQuickItem>
#include <map>
#include <QWidget>

using namespace std;

class KeyDelegate: public QObject
{
    Q_OBJECT

public:
    Q_PROPERTY(int block READ block WRITE setBlock)
    Q_PROPERTY(int shift READ block WRITE setBlock)
    Q_PROPERTY(int caps READ block WRITE setBlock)
    Q_PROPERTY(int alt READ block WRITE setBlock)
    Q_PROPERTY(int ctrl READ block WRITE setBlock)
    Q_PROPERTY(float rate READ rate)

    KeyDelegate(QObject *parent = 0);

    Q_INVOKABLE void handleKey(QString msg, QQuickItem* item, int pressed);
    Q_INVOKABLE void regist(QQuickItem* item);
    Q_INVOKABLE void loaded(QQuickItem *item);
    Q_INVOKABLE void move(QWidget* wid, int x, int y);

    void setBlock(int value);
    void setCaps(int value);
    void setShift(int value);
    void setCtrl(int value);
    void setAlt(int value);
    int block();
    float rate();
private:
    int m_block;
    float m_rate;
    int m_caps = 0;
    int m_shift = 0;
    int m_alt = 0;
    int m_ctrl = 0;

    map<QString, QQuickItem*> m_keyMap;
};

#endif // KEYDELEGATE_H
